<template>
  <el-dialog
    :width="width"
    :visible.sync="state.visible"
    :append-to-body="true"
  >
    <span slot="title" class="dialog-title">
      <span>{{ title }}</span>
      <div class="btn-box">
        <el-button @click="close">取 消</el-button>
        <el-button type="primary" @click="confirm">确 定</el-button>
      </div>
    </span>
    <slot name="content" />
  </el-dialog>
</template>
<script>
export default {
  name: 'SelectModal',
  props: {
    title: {
      type: String,
      default: '窗口'
    },
    width: {
      type: String,
      default: '50%'
    }
  },
  data() {
    return {
      state: {
        visible: false,
        bodyHeight: 320
      }
    }
  },
  created() {
    this.state.bodyHeight = window.innerHeight - 110
  },
  methods: {
    open() {
      this.state.visible = true
    },
    confirm() {
      this.$emit('confirm')
    },
    close() {
      this.state.visible = false
    }
  }
}
</script>
<style lang="scss">
.dialog-title{
  display: flex;
  justify-content: space-between;
}
.btn-box{
  margin-right: 20px;
}
</style>
